صفحه 1:
Python learning
Zahra Hossaini
صفحه 2:
عملگرهای محاسباتی
Meaning Example
‘Add two operands or unary plus 5 لا
Subtract right operand from the left or unary x -y
minus 2
Multiply two operands x*y
Divide left operand by the right one (always ری
results into float) y
۳ تن x%y
Modulus - remainder of the division of left 12° ¥ ser of
operand by the right 1
Floor division - division that results into whole
number adjusted to the left in the number ۱
line
Exponent - left operand raised to the power of x**y (x to the
right power y)
Operator
ae
صفحه 3:
ِ 2
عملگرهای مقایسه
Meaning Example
Greater that - True if left
operand is greater than the x > y
right
Less that - True if left
operand is less thanthe x <y
right
Equal to - True if both
operands are equal
Not equal to - True if
operands are not equal
Greater than or equal to -
True if left operand is
greater than or equal to the
right
Less than or equal to - True
if left operand is less than x <=y
or equal to the right
eH
x>=y
Operator
صفحه 4:
Example
xandy
xory
not x
عملگرهای منطقی
Meaning
True if both the
operands are true
True if either of the
operands is true
True if operand is false
(complements the
operand)
perator
and
or
not
صفحه 5:
عملگرهای منطق
Pistia
Piura
print
صفحه 6:
Example
x&y
xly
~x
x*y
<< 2
>> 2
عملكرهاى ستى
Meaning
Bitwise AND
Bitwise OR
Bitwise NOT
Bitwise XOR
Bitwise right shift
Bitwise left shift
Operator
صفحه 7:
عملگرهای انتساب
Equivalent to
x=5
بر + 5
بر 5
وير
x/5
دير 5
2 5
5
65
x=x|5
2 5
<< 5
K=x<<5
Example
x=5
x+=5
x-=5
*< 5
5
۷۱5
xe 5
x&=5
x|=5
5عمير
<<دير 5
x<<=5
Operator
صفحه 8:
identity Sue
دستورات زیر را اجرا کرده و پاسخ ها را توضیح دهید
xl=
yl=5
x2 = ‘Hello’
y2 = 'Hello‘
x3 = [1,2,3]
y3 = [1,2,3]
print(x1 is not y1)
print(x2 is y2)
print(x3 is y3)
صفحه 9:
عملگرهای عضویت
1 و 1 :1201 عملگرهایعضویندر ی کم جوعه مانند لیستهستند
x = 'Hello world’
Output: True #
print(‘H' in x)
Output: True #
print(‘hello' not in x)
Python learning
Zahra Hossaini
عملگرهای محاسباتی
Operator
Meaning
Example
+
Add two operands or unary plus
x+y
+2
-
Subtract right operand from the left or unary
minus
x-y
-2
*
Multiply two operands
x*y
/
Divide left operand by the right one (always
results into float)
x/y
%
Modulus - remainder of the division of left
operand by the right
x%y
(remainder of
x/y)
//
Floor division - division that results into whole
number adjusted to the left in the number
x // y
line
**
Exponent - left operand raised to the power of x**y (x to the
right
power y)
عملگرهای مقایسه
Operator
Meaning
Example
>
Greater that - True if left
operand is greater than the x > y
right
<
Less that - True if left
operand is less than the
right
x<y
==
Equal to - True if both
operands are equal
x == y
!=
Not equal to - True if
operands are not equal
x != y
>=
Greater than or equal to True if left operand is
x >= y
greater than or equal to the
right
<=
Less than or equal to - True
if left operand is less than
x <= y
or equal to the right
.
عملگرهای منطقی
perator
Meaning
Example
and
True if both the
operands are true
x and y
or
True if either of the
operands is true
x or y
not
True if operand is false
(complements the
operand)
not x
.
عملگرهای منطقی
.
عملگرهای بیتی
Operator
Meaning
Example
&
Bitwise AND
x& y
|
Bitwise OR
x |y
~
Bitwise NOT
~x
^
Bitwise XOR
x^y
>>
Bitwise right shift
x>> 2
<<
Bitwise left shift
x<< 2
.
عملگرهای انتساب
Operator
Example
Equivalent to
=
x=5
x=5
+=
x += 5
x=x+5
-=
x -= 5
x=x-5
*=
x *= 5
x=x*5
/=
x /= 5
x=x/5
%=
x %= 5
x=x%5
//=
x //= 5
x = x // 5
**=
x **= 5
x = x ** 5
&=
x &= 5
x=x&5
|=
x |= 5
x=x|5
^=
x ^= 5
x=x^5
>>=
x >>= 5
x = x >> 5
<<=
x <<= 5
x = x << 5
.
identity عملگر
x1 = 5
y1 = 5
x2 = 'Hello‘
y2 = 'Hello‘
x3 = [1,2,3]
y3 = [1,2,3]
print(x1 is not y1)
print(x2 is y2)
print(x3 is y3)
.دستورات زیر را اجرا کرده و پاسخ ها را توضیح دهید
عملگرهای عضویت
.یستهستند--ند ل-ان-جموعه م-کم--تدر ی-ضوی-ملگرهایع- عnot in وin
x = 'Hello world'
# Output: True
print('H' in x)
# Output: True
print('hello' not in x)